package resource.manager;

import android.app.Activity;
import android.net.TrafficStats;
import android.os.Bundle;
import android.widget.TextView;

public class TrafficInformation extends Activity {

	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.traffic);
        
        /*
         * Tx = Transmit  (packets transmitted out the interface)
		 * Rx = Recieve (packets received on the interface)
         */
        final TextView textMobileRxBytes = (TextView)findViewById(R.id.MobileRxBytes);
        final TextView textMobileRxPackets = (TextView)findViewById(R.id.MobileRxPackets);
        final TextView textMobileTxBytes = (TextView)findViewById(R.id.MobileTxBytes);
        final TextView textMobileTxPackets = (TextView)findViewById(R.id.MobileTxPackets);
        
        final TextView textTotalRxBytes = (TextView)findViewById(R.id.TotalRxBytes);
        final TextView textTotalRxPackets = (TextView)findViewById(R.id.TotalRxPackets);
        final TextView textTotalTxBytes = (TextView)findViewById(R.id.TotalTxBytes);
        final TextView textTotalTxPackets = (TextView)findViewById(R.id.TotalTxPackets);
        
		if(TrafficStats.getMobileRxBytes() == TrafficStats.UNSUPPORTED)
		{
			textMobileRxBytes.setText("MobileRxBytes: " + "UNSUPPORTED!");
		}
		else{
			textMobileRxBytes.setText("MobileRxBytes: " 
					+ String.valueOf(TrafficStats.getMobileRxBytes()));
		}
		
		if(TrafficStats.getMobileRxPackets() == TrafficStats.UNSUPPORTED)
		{
			textMobileRxPackets.setText("MobileRxPackets: " + "UNSUPPORTED!");
		}
		else{
			textMobileRxPackets.setText("MobileRxPackets: " 
					+ String.valueOf(TrafficStats.getMobileRxPackets()));
		}
		
		if(TrafficStats.getMobileTxBytes() == TrafficStats.UNSUPPORTED)
		{
			textMobileTxBytes.setText("MobileTxBytes: " + "UNSUPPORTED!");
		}
		else{
			textMobileTxBytes.setText("MobileTxBytes: " 
					+ String.valueOf(TrafficStats.getMobileTxBytes()));
		}
		
		if(TrafficStats.getMobileTxPackets() == TrafficStats.UNSUPPORTED)
		{
			textMobileTxPackets.setText("MobileTxPackets: " + "UNSUPPORTED!");
		}
		else{
			textMobileTxPackets.setText("MobileTxPackets: " 
					+ String.valueOf(TrafficStats.getMobileTxPackets()));
		}
		
		if(TrafficStats.getTotalRxBytes() == TrafficStats.UNSUPPORTED)
		{
			textTotalRxBytes.setText("TotalRxBytes: " + "UNSUPPORTED!");
		}
		else{
			textTotalRxBytes.setText("TotalRxBytes: " 
					+ String.valueOf(TrafficStats.getTotalRxBytes()));
		}
		
		if(TrafficStats.getTotalRxPackets() == TrafficStats.UNSUPPORTED)
		{
			textTotalRxPackets.setText("TotalRxPackets: " + "UNSUPPORTED!");
		}
		else{
			textTotalRxPackets.setText("TotalRxPackets: " 
					+ String.valueOf(TrafficStats.getTotalRxPackets()));
		}
		
		if(TrafficStats.getTotalTxBytes() == TrafficStats.UNSUPPORTED)
		{
			textTotalTxBytes.setText("TotalTxBytes: " + "UNSUPPORTED!");
		}
		else{
			textTotalTxBytes.setText("TotalTxBytes: " 
					+ String.valueOf(TrafficStats.getTotalTxBytes()));
		}
		
		if(TrafficStats.getTotalTxPackets() == TrafficStats.UNSUPPORTED)
		{
			textTotalTxPackets.setText("TotalTxPackets: " + "UNSUPPORTED!");
		}
		else{
			textTotalTxPackets.setText("TotalTxPackets: " 
					+ String.valueOf(TrafficStats.getTotalTxPackets()));
		}

   	        
        }
}